

import 'package:bst_web/common/dsliver.dart';
import 'package:bst_web/common/res.dart';
import 'package:bst_web/config.dart';

import 'controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mvc/flutter_mvc.dart';
import 'widget.dart';

///description:楼层市场
class Market1Page extends BasePage<Market1Controller> {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: const Color(0xffF2F2F4),
      child: Column(
        children: [
          Expanded(
            child: Row(
              children: [
                Expanded(
                  flex: 1,
                  child: ClipRect(
                    child: Stack(
                      children: [
                        LeftSelectItem(),
                        Stateful(
                            bind: () => [c.leftIndex],
                            builder: (context) {
                              return ListView.builder(
                                padding: EdgeInsets.only(bottom:  65.dp+Config.mediaQuery.padding.bottom),
                                controller: c.leftScrollController,
                                physics: const BouncingScrollPhysics(),
                                itemBuilder: (ctx, index) {
                                  return LeftItem(
                                      "市场:$index", index == c.leftIndex, () {
                                    c.onLeftItemClick(index);
                                  });
                                },
                                itemCount: 20,
                              );
                            }),
                      ],
                    ),
                  ),
                ),
                Expanded(
                  flex: 3,
                    child: Container(
                      color: Colors.white,
                      padding: EdgeInsets.only(left: 16.dp,right: 16.dp),
                      child: CustomScrollView(
                  physics: const BouncingScrollPhysics(),
                  slivers: _buildRight(),
                ),
                    ))
              ],
            ),
          ),
        ],
      ),
    );
  }

  List<Widget> _buildRight() {
    final list = <Widget>[];
    for (int i = 0; i < 5; i++) {
      list.add(SliverToBoxAdapter(child:RightGroupItem(i)));
      list.add(DSliverGrid(
        (ctx, index) {
          return RightItem();
        },
        childCount: 12,
        crossAxisCount: 3,
        mainAxisSpacing: 7.dp,
        crossAxisSpacing: 6.dp,
        childAspectRatio: RightItem.ratio,
      ));
    }
    list.add(SliverToBoxAdapter(child: Container(height:  65.dp+Config.mediaQuery.padding.bottom,),));
    return list;
  }
}
